{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# for 循环配合内置函数range()的使用\n",
    "### enumerate 枚举 产生steps的位置索引值（index)\n",
    "### for i in names:取到了names中的值（values）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "该时间秒的单位是奇数 ——当前时间节点为： 23\n",
      "等待 5\n",
      "not an odd second ——当前时间点为： 28\n",
      "等待 3\n",
      "该时间秒的单位是奇数 ——当前时间节点为： 31\n",
      "等待 5\n",
      "not an odd second ——当前时间点为： 36\n",
      "等待 2\n",
      "not an odd second ——当前时间点为： 38\n",
      "等待 4\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "import random\n",
    "import time\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "for i in range(5):\n",
    "    right_this_second = datetime.today().second\n",
    "    if right_this_second in odds:\n",
    "        print(\"该时间秒的单位是奇数\",\"——当前时间节点为：\", right_this_second)\n",
    "    else:\n",
    "        print(\"not an odd second\",\"——当前时间点为：\", right_this_second)\n",
    "    wait_time = random.randint(1,5)\n",
    "    print(\"等待\", wait_time)\n",
    "    time.sleep(wait_time)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
